  1 -- final.adb:  copy a file, character by character, to standard output
  2 
  3 with Ada.Text_IO, Ada.IO_Exceptions, Arg_Or_Default;
  4 use Ada;
  5 
  6 procedure Final is
  7 
  8    File_Name: constant String := Arg_Or_Default ("final.adb");
  9    File: Text_IO.File_Type;
 10    Char: Character;
 11 
 12 begin
 13 
 14    Text_IO.Open (File=>File, Mode=>Text_IO.In_File, Name=>File_Name);
 15    while not Text_IO.End_Of_File (File) loop
 16       while not Text_IO.End_Of_Line (File) loop
 17          Text_IO.Get (File=>File, Item=>Char);
 18          Text_IO.Put (Char);
 19       end loop;
 20       Text_IO.Skip_Line (File);  -- Move pointer in input buffer past EOL
 21       Text_IO.New_Line;          -- Write EOL to ouptut
 22    end loop;
 23    Text_IO.Close (File=>File);
 24 
 25 exception
 26 
 27    when IO_Exceptions.Name_Error =>
 28       Text_IO.Put_Line ("Couldn't open file '" & File_Name & "'.");
 29 
 30    when others =>
 31       Text_IO.Close (File=>File);
 32 
 33 end Final;